/************************************************************************

								Heroes IV
					  Copyright 2001, The 3DO Company

	------------------------------------------------------------------
  						 area_effect_point.h

	$Header:  $

	$NoKeywords: $

 ************************************************************************/

#if !defined( AREA_EFFECT_POINT_H_INCLUDED )
#define AREA_EFFECT_POINT_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "combat_creature_set.h"
#include "combat_creature_ptr.h"
#include "counted_ptr.h"
#include "map_point_list.h"
#include "random.h"
#include "uncopyable.h"


// A list of creatures which would be affected by
// an area-effect attack, plus the list of points
// that would produce the given list
class t_area_effect_point : public t_counted_object, private t_uncopyable
{
	public:
		t_area_effect_point();

		void add_creature(t_combat_creature_ptr creature);
		void add_point(const t_map_point_2d &point);
		void set_melee_target(const t_combat_creature *melee_target);
		void set_range_factor(int range_factor);

		const t_map_point_2d_list    &get_point_list(void) const;
		const t_combat_creature_set  &get_affected_list(void) const;
		const t_combat_creature      *get_melee_target(void) const;
		int                           get_range_factor(void) const;

	private:
		// The focal points of the attack -- the casting point if
		// a spell, the aiming point if a ranged attack, the 
		// "attack from" point if a melee attack. Attacking at/from
		// any of these points will produce the same list of affected
		// creatures
		t_map_point_2d_list m_point_list;

		// The list of creatures affected by this attack
		// Kept as a set so that it's always sorted and 
		// easier to compare
		t_combat_creature_set m_affected_list;

		// Target for melee attacks
		const t_combat_creature *m_melee_target;

		// For ranged attacks: the range factor of all the points
		int m_range_factor;
};

inline 
t_area_effect_point::t_area_effect_point(void)
	: m_melee_target(NULL), m_range_factor(0)
{
}


// Note that another creature is affected by this target point
inline
void t_area_effect_point::add_creature(t_combat_creature_ptr creature)
{
	m_affected_list.insert(creature);
}

// Note that another point affects this list of creatures
inline
void t_area_effect_point::add_point(const t_map_point_2d &point)
{
	m_point_list.push_back(point);
}

inline
void t_area_effect_point::set_range_factor(int range_factor)
{
	m_range_factor = range_factor;
}

inline
const t_map_point_2d_list &t_area_effect_point::get_point_list(void) const
{
	return m_point_list;
}

inline
const t_combat_creature_set &t_area_effect_point::get_affected_list(void) const
{
	return m_affected_list;
}

inline
const t_combat_creature *t_area_effect_point::get_melee_target(void) const
{
	return m_melee_target;
}

inline
int t_area_effect_point::get_range_factor(void) const
{
	return m_range_factor;
}

#endif // AREA_EFFECT_POINT_H_INCLUDED
